import { createSlice } from "@reduxjs/toolkit";
import { setDefaultConfig } from "antd-mobile";
let cart = createSlice({
    name: "cart",
    initialState: {
        list: [],
        //订单跟踪状态
        orderTrack: '-1',
        //当前用户手机号
        myPhone: ''
    },
    reducers: {
        addList(state, actions) {
            let newList = state.list
            newList.push(actions.payload)
            state.list = newList
        },
        addDel(state, actions) {
            let newList = state.list
            newList = []
            state.list = newList
        },
        //设置订单跟踪
        addTrack(state, actions) {
            console.log(actions);
            state.orderTrack = ''
            let newTrack = state.orderTrack
            newTrack = actions.payload
            state.orderTrack = newTrack
        },
        //接收手机号
        addPhone(state, actions) {

            state.myPhone = ''
            let newPhone = state.myPhone
            newPhone = actions.payload
            state.myPhone = newPhone
        }
    }
})

export let { addList, addDel, addTrack, addPhone } = cart.actions;
export default cart.reducer;